﻿# region Copyrights Notice
//©2009 Microsoft Corporation.  All rights reserved.
//This portal design is based on the design and some code from DropThings.com which is also licensed under an MS-PL license.
#endregion

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Microsoft.InformationSecurity.RiskManagement.ISRMWeb
{

    /// <summary>
    /// Custom site map provider to perform role checking.
    /// </summary>
    public class CISFSiteMapProvider:XmlSiteMapProvider
    {
        public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
        {
            if (node.Roles.Contains("*"))
                return true;

            foreach (string roleName in node.Roles)
            {
                if (context.User.IsInRole(roleName))
                {
                    return true;
                }
            }
            return false;
        }
    }
}
